The UCollationElements is used as an iterator to walk through each character of an international string
The UCollationElements is used as an iterator to walk through each character of an international string. Use the iterator to return the ordering priority of the positioned character. The ordering priority of a character, which we refer to as a key, defines how a character is collated in the given collation object. For example, consider the following in Spanish:
.       "ca" -> the first key is key('c') and second key is key('a').
.       "cha" -> the first key is key('ch') and second key is key('a').
And in German,
.       "�b"-> the first key is key('a'), the second key is key('e'), and
.       the third key is key('b').
The key of a character, is an const UCOL_PRIMARYMASK, UCOL_SECONDARY_MASK, UCOL_TERTIARYMASK.

Example of the iterator usage: (without error checking)

.  void CollationElementIterator_Example()
.  {
.      UChar *s;
.      t_int32 order, primaryOrder;
.      UCollationElements *c;
.      UCollator *coll;
.      UErrorCode success = U_ZERO_ERROR;
.      s=(UChar*)malloc(sizeof(UChar) * (strlen("This is a test")+1) );
.      u_uastrcpy(s, "This is a test");
.      coll = ucol_open(NULL, &success);
.      c = ucol_openElements(coll, str, u_strlen(str), &status);
.      order = ucol_next(c, &success);
.      primaryOrder = order & UCOL_PRIMARYMASK;
.      free(s);
.      ucol_close(coll);
.      ucol_closeElements(c);
.  }

ucol_next() returns the collation order of the next character based on the comparison level of the collator. A collation order consists of primary order, secondary order and tertiary order. The data type of the collation order is t_int32. The first 16 bits of a collation order is its primary order; the next 8 bits is the secondary order and the last 8 bits is the tertiary order.

See Also:
Collator

alphabetic index hierarchy of classes


this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de